<?php

/**
 * MlMachines form.
 *
 * @package    maslogger
 * @subpackage form
 * @author     Michaël VEROUX
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class MlMachinesForm extends BaseMlMachinesForm
{
  public function configure()
  {
  	unset($this['created_at'],$this['updated_at'],$this['deleted_at'],$this['version']);
  	
  	$this->widgetSchema['suggest_box'] = new sfWidgetFormJQueryAutocompleter(array(
       'url'    => "ajaxEdit",
       'config' => '{ scrollHeight: 250 ,
                      autoFill: false }',
       'response' => 'window.location.href = \'/machine/\' + data[1] + \'/edit\';'
       ),array('class' => 'emptyonfocus'));
  	$this->setWidget('denomination', new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => $this->getRelatedModelName('MlDenominations'), 'add_empty' => false)));
        
  	//$this->setWidget('date_mise_service',new sfWidgetFormJQueryDate());
        //$this->setWidget('date_cessation', new sfWidgetFormJQueryDate());
  	
        $years = range(date('Y') - 30, date('Y') + 1);
        
        $this->setWidget('date_mise_service',new sfWidgetFormDate(array('format' => '%day%/%month%/%year%', 'years' => array_combine($years, $years))));
        $this->setWidget('date_cessation',new sfWidgetFormDate(array('format' => '%day%/%month%/%year%', 'years' => array_combine($years, $years))));
        
  	$this->setValidator('denomination',new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => $this->getRelatedModelName('MlDenominations'))));
  	$this->setValidator('date_mise_service',new sfValidatorDate(array('required' => true)));
  }
}
